package cn.leo.muliti_datasource.config;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @author leo.z.l
 * @create 2019-09-04  14:45
 */
@Configuration
public class DBConfig {

    @Bean
    @Primary
    @ConfigurationProperties("spring.datasource.first")
    public DataSource firstDatasource() {
        return DruidDataSourceBuilder.create().build();
    }

    @Bean
    @ConfigurationProperties("spring.datasource.second")
    public DataSource secondDatasource() {
        return DruidDataSourceBuilder.create().build();
    }

}
